package com.heisenhub.system.controller;


import com.heisenhub.common.oauth.annotation.ApiResourceOpen;
import com.heisenhub.common.oauth.enums.RESTAPI;
import com.heisenhub.system.service.IUserService;
import com.heisnenhub.common.module.utils.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author sen
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    /**
     * 获取登入用户
     * @param username
     * @return
     */
    @ApiResourceOpen(value = RESTAPI.INTERIOR)
    @RequestMapping("findUserByUsername")
    public Api LoginByName(@RequestParam("username") String username){
        return Api.ok(userService.findByName(username));
    }

    /**
     * 获取用户权限
     * @param username
     * @return
     */
    @RequestMapping("findUserPermissions")
    public Api findUserPermissions(@RequestParam("username") String username){
        return Api.ok(userService.findUserPermissions(username));
    }
}
